<%@ Page Title="MvcCms Edit Page" Language="C#" MasterPageFile="~/Views/Shared/EditPage.Master" Inherits="System.Web.Mvc.ViewPage<MvcCms.Data.ContentPage>" %>

<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
    <%if (!Model.Portal.UsesWikiForCMS && !Model.UseWikiMarkup)
      {
    %>
    <script type="text/javascript" src="/scripts/MvcCmsImageManager.js"></script>
    <script type="text/javascript" src="/scripts/ckeditor/ckeditor.js"></script>
    <script src="/scripts/ckeditor.js" type="text/javascript"></script>
    <link href="/content/ckeditor.css" rel="stylesheet" type="text/css" />
    <script id="headscript" type="text/javascript">
        var editor;
        function changeEnter() {
            // If we already have an editor, let's destroy it first.
            if (editor)
                editor.destroy(true);

            // Create the editor again, with the appropriate settings.
            editor = CKEDITOR.replace('Body',
		    {
		        enterMode: Number(1),
		        shiftEnterMode: Number(2),
		        height: "430"
		    });
            MvcCmsImages.SetupCKEditor(editor);
        }
        window.onload = changeEnter;
        //]]>
    </script>
    <%
      }
      else
      {
    %>
    <script src="/Scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="/scripts/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
    <link href="/Content/dark-hive/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" />
    <%}%>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="maincontent" runat="server">
    <%= Html.ValidationSummary("Edit was unsuccessful. Please correct the errors and try again.") %>
    <span class="field-validation-error">&nbsp;<%=ViewData["message"].ToString()%></span>
    <% using (Html.BeginForm("editcontentpage/" + Model.ContentPageID.ToString(), "backoffice"))
       {%>
    <%if (!Model.Portal.UsesWikiForCMS && !Model.UseWikiMarkup)
      {%>
    <div>
        <span>
            <strong><%=Model.Title %></strong>
        </span>
    </div>
    <p>
        <%= Html.TextArea("Body", Model.Body)%>
        <%= Html.ValidationMessage("Body", "")%>
    </p>
    <%}
      else
      {%>
    <div class="left">
        <div id="tabs">
            <div>
                This Portal or Page Uses Wiki Code For Markup</div>
            <ul>
                <li><a href="#tabs-compose">Compose</a></li>
                <li><a href="#tabs-preview">Preview</a></li>
            </ul>
            <div id="tabs-compose">
                <%= Html.TextArea("Body", Model.Body, new { @class="editor-ta" })%>
            </div>
            <div id="tabs-preview">
                <div id="previewWikiContent" class="preview">
                </div>
            </div>
        </div>
    </div>
    <div class="right">
        <div>
            <h3 class="Header">
                Wiki Markup Guide</h3>
            <div class="Markup">
                *bold*</div>
            <div class="Markup">
                _italics_</div>
            <div class="Markup">
                +underline+</div>
            <div class="Markup">
                ! Heading 1</div>
            <div class="Markup">
                !! Heading 2</div>
            <div class="Markup">
                * Bullet List</div>
            <div class="Markup">
                ** Bullet List 2</div>
            <div class="Markup">
                # Number List</div>
            <div class="Markup">
                ## Number List 2</div>
            <div class="Markup">
                [url:http://www.example.com]</div>
            <div class="Markup">
                {&quot;Do not apply formatting&quot;}</div>
            <div>
                <a id="f2d9c033-cdb1-47a5-a31b-3413465e7e86_WikiFormattingGuide_FullGuideLink" class="ArrowSmall"
                    href="/forums/faq" target="_blank">Full Markup Guide</a>
            </div>
        </div>
    </div>
    <div class="clear">
    </div>
    <%} %>
    <p>
        <%= Html.Hidden("editpagelink", ViewData["editpagelink"].ToString())%>
        <input type="submit" id="updateBut" value="Submit Changes" />
    </p>
    <%}%>
</asp:Content>
<asp:Content ID="editScriptContent" ContentPlaceHolderID="scriptContent" runat="server">
    <%if (Model.Portal.UsesWikiForCMS || Model.UseWikiMarkup)
      {%>
    <script type="text/javascript">
        $(document).ready(function () {
            $(function () {
                $("#tabs").tabs();

                $("#tabs").bind("tabsselect", function (event, ui) {
                    var selectedTab = $("#tabs").tabs().data("selected.tabs");
                    if (selectedTab == 0) {
                        $.post('/wiki/home/GetWikiPreview',
                           { source: $("#Body").val() },
                           function (data) { $('#previewWikiContent').html(data); });
                    }
                });
            });
        });     
    </script>
    <%} %>
</asp:Content>
